from odoo import models, fields, api

class AccountChangeLockDate(models.TransientModel):
    """
    This wizard is used to change the lock date
    """
    _name = 'account.change.lock.date'
    _description = 'Change Lock Date'

    period_lock_date = fields.Date(
        string='Lock Date for Non-Advisers')

    voucher_id = fields.Many2many('accountcore.voucher')

    def change_lock_date(self):
        for record in self:
            for r in record.voucher_id:
                r.lock_date = self.period_lock_date
                r.state = 'locked'
        return {'type': 'ir.actions.act_window_close'}
